This repository was archived by the owner on Oct 13, 2023. It is now read-only.
[19.03 backport] Use correct LOOP_CTL_GET_FREE API in pkg/loopback#347
Merged
thaJeztah merged 1 commit intodocker-archive:19.03from Sep 6, 2019
Merged
Conversation
The `ioctl` interface for the `LOOP_CTL_GET_FREE` request on `/dev/loop-control` is a little different from what `unix.IoctlGetInt` expects: the first index is the returned status in `r1`, not an `int` pointer as the first parameter. Unfortunately we have to go a little lower level to get the appropriate loop device index out, using `unix.Syscall` directly to read from `r1`. Internally, the index is returned as a signed integer to match the internal `ioctl` expectations of interpreting a negative signed integer as an error at the userspace ABI boundary, so the direct interface of `ioctlLoopCtlGetFree` can remain as-is. [@kolyshkin: it still worked before this fix because of /dev scan fallback in ioctlLoopCtlGetFree()] Signed-off-by: Daniel Sweet <danieljsweet@icloud.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> (cherry picked from commit db2bc43) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR moby#39801
The
ioctlinterface for theLOOP_CTL_GET_FREErequest on/dev/loop-controlis a little different from whatunix.IoctlGetIntexpects: the first index is the returned status in
r1, not anintpointer as the first parameter.
Unfortunately we have to go a little lower level to get the appropriate
loop device index out, using
unix.Syscalldirectly to read fromr1. Internally, the index is returned as a signed integer to match theinternal
ioctlexpectations of interpreting a negative signed integeras an error at the userspace ABI boundary, so the direct interface of
ioctlLoopCtlGetFreecan remain as-is.[@kolyshkin: it still worked before this fix because of
/dev scan fallback in ioctlLoopCtlGetFree()]